#region Microsoft Public License
/*
 * (c) Copyright Chenjun Wu. http://utablesdk.codeplex.com
 * 
 * This source is subject to the Microsoft Public License (Ms-PL).
 * Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
 * All other rights reserved.
 */
#endregion

﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UTable.Objects;
using System.Collections.ObjectModel;

namespace UTable.Input.MultiTouch
{
    class LocalMultitouchInputMapper : MultiTouchInputMapper
    {
        public override Collection<ManagedInputEventArgs> MapInput(InputEventArgs args)
        {
            if (args is MultiTouchEventArgs)
            {
                MultiTouchEventArgs a = new MultiTouchEventArgs(args.Timestamp);

                /*
                foreach (FingerEventArgs f in (args as MultiTouchEventArgs).FingerEvents)
                {
                    Console.WriteLine(f.FingerID + ", " + f.EventType + ", " + f.Position);
                }*/


                foreach (FingerEventArgs f in (args as MultiTouchEventArgs).FingerEvents)
                {
                    if (f.EventType != FingerEventType.FINGER_IN_EVENT && f.EventType != FingerEventType.FINGER_OUT_EVENT)
                        a.FingerEvents.Add(f);
                }
                Collection < ManagedInputEventArgs > result = base.MapInput(a);

                /*
                foreach (ManagedInputEventArgs r in result)
                {
                    Console.WriteLine("Receiver: " + r.Receiver);
                }
                Console.WriteLine();*/


                return result;
            }
            // Console.WriteLine("False Input");
            return base.MapInput(args); ;
        }

        public override bool CaptureFinger(IVisualNode node, int fingerId, bool fromGlobal)
        {
            return base.CaptureFinger(node, fingerId, fromGlobal);
        }

        public override bool UncaptureFinger(IVisualNode node, int fingerId)
        {

            return base.UncaptureFinger(node, fingerId);
        }
    }
}
